/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package HealthMonitoringView;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;

/**
 *
 * @author Tuan
 */
public class AbstractForm extends Form implements CommandListener{
    protected Command exitCommand;
    
    protected Command backCommand;
    
    protected Command mainCommand;
    
    protected Command clusteringCommand;
    
    protected Command monitoringCommand;
    
    protected Command dataEntryCommand;
    
    protected MIDletNavigation parent;
    
    public AbstractForm(String title, Item[] items, MIDletNavigation parent){
        super(title, items);
        this.parent = parent;
        this.initialize();
    }
    
    protected void initialize(){
        this.backCommand = new Command("Back", Command.BACK, 0);
        this.mainCommand = new Command("Home", Command.ITEM, 1);
        this.monitoringCommand = new Command("Monitoring Form", Command.ITEM, 2);
        this.clusteringCommand = new Command("Clustering Form", Command.ITEM, 3);
        this.dataEntryCommand = new Command("Entry Data Form", Command.ITEM, 4);
        this.exitCommand = new Command("Exit", Command.ITEM, 5);
        
        this.addCommand(backCommand);
        this.addCommand(mainCommand);
        this.addCommand(monitoringCommand);
        this.addCommand(clusteringCommand);
        this.addCommand(dataEntryCommand);
        this.addCommand(exitCommand);
        
        this.setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if(c == backCommand){
            this.parent.goBack();
        } else if(c == mainCommand) {
            this.parent.showMain();
        } else if(c == monitoringCommand) {
            this.parent.showMonitoringForm();
        } else if(c == clusteringCommand) {
            this.parent.showClusteringForm(true);
        } else if(c == exitCommand) {
            this.parent.exit();
        } else if(c == dataEntryCommand) {
            this.parent.showEntryDataForm();
        }
    }
}
